﻿namespace QiangPiao
{
    using SQ.Base;
    using System;
    using System.ComponentModel;
    using System.Drawing;
    using System.Windows.Forms;

    public class FrmYDCfm : Form
    {
        private Button btnCancel;
        private Button btnOK;
        protected internal CheckBox chkSend100;
        private IContainer components = null;
        private FrmMain frmMain;
        public bool IsCancel;
        private Label label2;
        private PictureBox picCheckCode;
        protected internal TextBox txtCheckCode;

        public FrmYDCfm(FrmMain frmMain)
        {
            this.InitializeComponent();
            this.frmMain = frmMain;
            this.chkSend100.Enabled = true;//PublicInfo.AuthorizeInfo.ForceTimes > 1;
            this.RefreshCheckCode();
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.IsCancel = true;
            base.Close();
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            if(string.IsNullOrWhiteSpace(this.txtCheckCode.Text))
            {
                MessageBox.Show("验证码必须输入!", "提醒", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
            else
            {
                base.Close();
            }
        }

        protected override void Dispose(bool disposing)
        {
            if(disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void InitializeComponent()
        {
            this.picCheckCode = new PictureBox();
            this.txtCheckCode = new TextBox();
            this.label2 = new Label();
            this.btnOK = new Button();
            this.btnCancel = new Button();
            this.chkSend100 = new CheckBox();
            ((ISupportInitialize)this.picCheckCode).BeginInit();
            base.SuspendLayout();
            this.picCheckCode.Cursor = Cursors.Hand;
            this.picCheckCode.Location = new Point(0x92, 12);
            this.picCheckCode.Name = "picCheckCode";
            this.picCheckCode.Size = new Size(0x4e, 0x1a);
            this.picCheckCode.TabIndex = 5;
            this.picCheckCode.TabStop = false;
            this.picCheckCode.Click += new EventHandler(this.picCheckCode_Click);
            this.txtCheckCode.Location = new Point(0x41, 0x11);
            this.txtCheckCode.Name = "txtCheckCode";
            this.txtCheckCode.Size = new Size(0x4b, 0x15);
            this.txtCheckCode.TabIndex = 6;
            this.label2.AutoSize = true;
            this.label2.Location = new Point(12, 20);
            this.label2.Name = "label2";
            this.label2.Size = new Size(0x2f, 12);
            this.label2.TabIndex = 4;
            this.label2.Text = "验证码:";
            this.btnOK.Location = new Point(0x41, 0x2c);
            this.btnOK.Name = "btnOK";
            this.btnOK.Size = new Size(0x4b, 0x17);
            this.btnOK.TabIndex = 7;
            this.btnOK.Text = "确定";
            this.btnOK.UseVisualStyleBackColor = true;
            this.btnOK.Click += new EventHandler(this.btnOK_Click);
            this.btnCancel.Location = new Point(0x92, 0x2c);
            this.btnCancel.Name = "btnCancel";
            this.btnCancel.Size = new Size(0x4b, 0x17);
            this.btnCancel.TabIndex = 7;
            this.btnCancel.Text = "取消";
            this.btnCancel.UseVisualStyleBackColor = true;
            this.btnCancel.Click += new EventHandler(this.btnCancel_Click);
            this.chkSend100.AutoSize = true;
            this.chkSend100.Location = new Point(11, 0x30);
            this.chkSend100.Name = "chkSend100";
            this.chkSend100.Size = new Size(0x30, 0x10);
            this.chkSend100.TabIndex = 8;
            this.chkSend100.Text = "暴力";
            this.chkSend100.UseVisualStyleBackColor = true;
            base.AcceptButton = this.btnOK;
            base.AutoScaleDimensions = new SizeF(6f, 12f);
            //base.AutoScaleMode = AutoScaleMode.Font;
            base.ClientSize = new Size(0xef, 0x4d);
            base.Controls.Add(this.chkSend100);
            base.Controls.Add(this.btnCancel);
            base.Controls.Add(this.btnOK);
            base.Controls.Add(this.picCheckCode);
            base.Controls.Add(this.txtCheckCode);
            base.Controls.Add(this.label2);
          
            base.Name = "FrmYDCfm";
            base.StartPosition = FormStartPosition.CenterScreen;
            this.Text = "确定";
            ((ISupportInitialize)this.picCheckCode).EndInit();
            base.ResumeLayout(false);
            base.PerformLayout();
        }

        private void picCheckCode_Click(object sender, EventArgs e)
        {
            this.RefreshCheckCode();
        }

        private void RefreshCheckCode()
        {
            try
            {
                this.picCheckCode.Image = this.frmMain.http.Getimg("https://dynamic.12306.cn/otsweb/passCodeAction.do?rand=randp&" + new Random().NextDouble(), "image/png,image/*;q=0.8,*/*;q=0.5");
            }
            catch(Exception exception)
            {
                MessageBox.Show(exception.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                Log.WriteLog4Ex("RefreshCheckCode", exception);
            }
        }
    }
}

